<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      
      >
      <head>
      
        <link rel="stylesheet" type="text/css" href="../css/data.css"/>
        <link rel="stylesheet" type="text/css" href="../css/prime.css"/>
        <script type="text/javascript" language="JavaScript3.1">
       
           
            
            
            var validProps=null;
            var patterns=null;
            function parseMap(propMap,propKey){
                 var res=null;
                 var props=propMap.substring(1,propMap.length-1);
                 var p=props.split(",");
                 for(var i=0; i &lt; p.length;i++) {
                     if(p[i].indexOf(propKey)!=-1) {
                            var k=p[i].split("=");

                            for(var j=0;j &lt; k.length;j++) { 
                            if(k[j].trim()==propKey) {
                                 res=k[j+1];
                                 break;
                                }
                           }
                            
                         }
                     }
                 return res;
            }
                
            function validateFileSize(siz,maxSize){
                var res=false;
                var a=parseFloat(siz);
                var b=parseFloat(maxSize);
                
                if(a &lt; b) {
                    res=true;
                }
                
                return res;
            }
            
           
            
            function validateFileName(val,pat){
                 var res = false;
                  
                 if(pat==null) {
                     return res;
                 }
                 
                 var reg = new RegExp(pat.trim().toUpperCase());

                 if(val.trim().toUpperCase().match(reg)) {
                     res=true;
                 }
                
                return res;
                
            }
                
             function flushFiles(){
                 up_files=document.getElementById("up_files");
                 up_files.style.color="grey";
                 validProps = null;
                 var files=document.getElementById("browse_files");
                 files.value=null;
                 var table = document.querySelector("#file_list_to_upload>table");
                 var divUploadFiles=document.getElementById("file_list_to_upload");
                 var divMessage=document.getElementById("file_list_note");
                 divUploadFiles.style.height="0px";
                 divMessage.style.height="0px";
                
                 while (table.hasChildNodes()) {
                     table.removeChild(table.firstChild);
                 }
                 while(divMessage.hasChildNodes()) {
                       divMessage.removeChild(divMessage.firstChild); 
                 }
             }

             var up_files=null;
             
             function validateFileNameByAllPatterns(currFileName,allPatterns){
                 var valid=false;
                  var patternsList=allPatterns.split(",");
                  for(var i=0;i &lt; patternsList.length;i++) {
                      if(validateFileName(currFileName,patternsList[i])) {
                          valid=true;
                          break; 
                        } 
                  }
                  return valid;
             }
             
             function listFiles() {
                    validProps = document.getElementById("validProps").value;
                    patterns=document.getElementById("xlsPatterns").value;
                    
                    if(validProps==null) {
                      alert("Could not load following validation properties from database!\n fina2.mfb.xls.name.pattern \n fina2.xls.max.size\n fina2.zip.max.size");
                    }
                    if(patterns==null) {
                    	alert("Could not load any pattern!");
                    }else {
                    	patterns=patterns.substring(1,patterns.length-1);
                    }
                    var input = document.querySelector("input[type='file']");
                    var table = document.querySelector("#file_list_to_upload>table");
                    var divUploadFiles=document.getElementById("file_list_to_upload");
                    var divMessage=document.getElementById("file_list_note");
                   
                    divMessage.style.height="12px";
                        
                   
                    var length=input.files.length;

                    if(length==0) {
                        divUploadFiles.style.height="0px";
                    }
                    else if(length==1) {
                        divUploadFiles.style.height="33px";
                    } 
                    else if(length==2) {
                        divUploadFiles.style.height="53px";
                    } 
                    else if(length==3) {
                        divUploadFiles.style.height="73px";
                    } 
                    else {
                        divUploadFiles.style.height="100px";
                    }

                    while(divMessage.hasChildNodes()) {
                        divMessage.removeChild(divMessage.firstChild);
                    }
                    while (table.hasChildNodes()) {
                        table.removeChild(table.firstChild);
                    }
                   
                    
                    var p=document.createElement("p");
                    var b=document.createElement("b");
                    b.innerHTML="Invalid Values Are Shown In Red";
                    p.appendChild(b);
                    divMessage.appendChild(p);
                    
                    var tr=document.createElement("tr");
                    tr.id="0"
                    var td_header_name = document.createElement("td");
                    var td_header_size = document.createElement("td");
                    td_header_name.style.backgroundColor="#D6E6FB";
                    td_header_size.style.backgroundColor="#D6E6FB";
                    td_header_name.style.borderRight="1px solid #C0C0C0";
                    td_header_name.style.borderBottom="1px solid #C0C0C0";
                    td_header_name.innerHTML="File Name";
                    td_header_size.innerHTML="Size";
                    td_header_size.style.borderBottom="1px solid #C0C0C0";
                    tr.appendChild(td_header_name);
                    tr.appendChild(td_header_size);
                    table.appendChild(tr);
                    
                    var errorCounter=0;
                    
                    for(var i=0; i&lt;length; i++) {
                        var tr_i=document.createElement("tr");
                        tr_i.id=(i+1);
                        
                        var td_name = document.createElement("td");
                        var td_size=document.createElement("td");
                        var fileName=input.files[i].name;
                        var size=input.files[i].size;
                      
                        td_name.style.borderRight="1px solid #C0C0C0";
                        
                        td_name.innerHTML =fileName;
                        td_size.innerHTML=(size/1024).toFixed(2)+" KB";
                        
                        if(i+1!=length) {
                        td_name.style.borderBottom="1px solid #C0C0C0";
                        td_size.style.borderBottom="1px solid #C0C0C0";
                        }

                        var xlsNamePattern=parseMap(validProps,"fina2.mfb.xls.name.pattern");
                        var xlsHistNamePattern=parseMap(validProps,"fina2.mfb.xls.historic.name.pattern");
                        var zipNamePattern=null;
                        var zipMaxSize=parseMap(validProps,"fina2.zip.max.size");
                        var xlsMaxSize=parseMap(validProps,"fina2.xls.max.size");
                        var isZip=(fileName.toLowerCase().indexOf(".zip")!=-1)?true:false;
                        var isXml=(fileName.toLowerCase().indexOf(".xml")!=-1)?true:false;
                        
                        var list="";
                        
                        if(xlsHistNamePattern==null)
                            list+="XLS Historic Name Pattern: fina2.mfb.xls.historic.name.pattern\n"; 
                        if(xlsNamePattern==null)
                            list+="XLS Name Pattern: fina2.mfb.xls.name.pattern\n";
                        if(zipMaxSize==null)
                            list+="Zip Max Size: fina2.zip.max.size\n";
                        if(xlsMaxSize==null)
                            list+="XLS Max Size: fina2.xls.max.size\n";
                        
                        var message;
                        
                        
                        if(list.trim().length!=0) {
                               message="The Following Properties are required but not loaded from database:\n"+list
                               alert(message);
                               flushFiles();
                               Richfaces.hideModalPanel("uploadFile");
                        }
                      
                        var siz=(size/1024).toFixed(2);
                        
                        if(isZip) {
                            
                           

                            if(!validateFileNameByAllPatterns(fileName.toLowerCase().replace(".zip",".xls"),patterns.toLowerCase().replace(".zip",".xls"))) {
                               td_name.style.color="red";  
                               errorCounter++;
                            }
                       
                            if(!validateFileSize(siz,zipMaxSize)) {
                               td_size.style.color="red";
                               errorCounter++; 
                            }
                        } else if(isXml){
                            
                        }else {
                        	if(!validateFileNameByAllPatterns(fileName,patterns)) {
                        		td_name.style.color="red";
                                errorCounter++;
                        	}
                            
                             if(!validateFileSize(siz,xlsMaxSize)) {
                                td_size.style.color="red";
                                errorCounter++; 
                              }
                        }
                        
                        tr_i.appendChild(td_name);
                        tr_i.appendChild(td_size);
                        table.appendChild(tr_i);
                       
                    }
                    
                   
                    
                    if(errorCounter==0) {
                      up_files.disabled=false;  
                      up_files.style.color="";
                    }
                    else {
                      up_files.disabled=true;
                      up_files.style.color="grey";
                    }
             }
           
            
             var ids="";
             var checkedCounter=0;
             var all=false;
             function saveUpdateId(checkBoxItem) {
                var id=checkBoxItem.id;
                var checked=checkBoxItem.checked;
               
                if(checked) {
                   checkedCounter++;
                   if(ids.indexOf(","+id+",")==-1) {
                       ids+=","+id+",";
                   }    
                }
                else {
                  checkedCounter--;
                  if(ids.indexOf(","+id+",")!=-1) {
                     ids=ids.replace(","+id+",","");
                  }
                }
              
               
              updateToolBar();
             }
             
             function updateToolBar(){
                 
                  var remove_image=document.getElementById("remove_image");
                  var download_image=document.getElementById("download_image");
                  var download_link=document.getElementById("download_form_link");
                  var remove_link=document.getElementById("remove_form_link");
                  
                 
                  
                  if(ids!="") {
                      document.getElementById("download_form").action="Download?id="+ids;
                      download_link.href="Download?id="+ids;
                      document.getElementById("remove_form").action="Remove?id="+ids;
                      remove_link.href="Remove?id="+ids;
                      remove_link.onclick=function(){ return confirm("Would you like to remove selected files?")};
                  }
                  else {
                     
                      document.getElementById("download_form").action="Download?id="+ids;
                      download_link.onclick=function(){ if(checkedCounter==0)return false };
                      document.getElementById("remove_form").action="Download?id="+ids;
                      remove_link.onclick=function(){ if(checkedCounter==0)return false };
                      }
                 
                  
                 if(checkedCounter==0 || ids=="" || ids==null) {
                   remove_image.style.opacity=0.4;
                   remove_image.style.cursor="auto";
                   remove_link.style.cursor="auto";  
                   download_image.style.opacity=0.4;
                   download_image.style.cursor="auto";
                   download_link.style.cursor="auto";
                 }
                 else {
                   remove_image.style.opacity=1.0;
                   remove_image.style.cursor="pointer";
                   remove_link.style.cursor="pointer";
                   download_image.style.opacity=1.0;
                   download_image.style.cursor="pointer";
                   download_link.style.cursor="pointer";
                 }
              }
            
             
             function suggestRemove(){
                return confirm("Would you like to remove selected files?");
             }
             function viewSelected() {
                 var v=ids.split(",");
                
                 for(var i=0;i &lt; v.length;i++) {
                     if(v[i]==null)
                         continue;
                   var b=document.getElementById(""+v[i]);
                   
                   if(b!=null) {
                        b.checked=true;
                    }
                  if(all)
                      document.getElementById("select_deselect").checked=true;
                  else 
                      document.getElementById("select_deselect").checked=false;
                 }    
              }
             
             function selectAllFiles(){
                 var items=document.getElementById("file_item_ids").value;
                 items=items.replace("[","");
                 items=items.replace("]","");
                 var vv=items.split(",");
                 ids="";
                 var k=0;
                 for(var i=0;i&lt;vv.length;i++) {
                     if(vv[i]==null || vv[i].trim()=="")
                         continue; {
                             k++;
                      ids+=","+vv[i].trim()+",";
                         }
                     }
                
                 viewSelected();
                
            
                 if(k>0)
                    checkedCounter=vv.length;
                 else 
                    checkedCounter=0;
                 updateToolBar();
             }

             function deselectAllFiles(){
                 var vv=ids.split(",");
                 for(var i=0;i&lt;vv.length;i++) {
                     if(vv[i]==null)
                         continue;
                     var b=document.getElementById(""+vv[i]);
                     if(b!=null)
                         b.checked=false;
                     }
                 ids="";
                 checkedCounter=0;
                 viewSelected();
                
                
                 
                 updateToolBar();
             }

             function selectDeselectAll() {
                 var v=document.getElementById("select_deselect");
                 
                  if(v.checked) {
                      all=true;
                      selectAllFiles();
                      v.title="Deselect All";
                  }    
                  else {
                      all=false;
                      deselectAllFiles();
                      v.title="Select All";
                  }
             }
        </script>
        
      </head>
      <body style="font-size:11px">
      
    
    <rich:toolBar id="data_toolbar"  itemSeparator="line"  >
    <rich:toolBarGroup >
        
        <form id="download_form" action="Download?id=" style="font-size:0px">
            <a id="download_form_link" onclick="if(checkedCounter==0){ return false;}" href="Download?id=" style="cursor:auto">
                <img id="download_image" title="Download Selected Files" src="../images/save.gif" style="border:0px;opacity:0.4"/>
            </a>    
        </form>
        
        <s:link title="Refresh" onclick="Richfaces.showModalPanel('loading')" action="#{uploadBean.refreshData()}" rendered="#{menuManager.pageUrl=='../security/data.seam'}" reRender="filesForm:data_banks,filesForm:data_users"  id="refresh_data" >
            <h:graphicImage value="../images/refresh.gif" style="width:16px; height:16px;border:0" />
        </s:link>
        
        <form id="remove_form" action="Remove?id="  style="font-size:0px">
            <a id="remove_form_link" onclick="if(checkedCounter==0){return false} else {Richfaces.showModalPanel('loading')}" href="Remove?id=" style="cursor:auto">
                <img id="remove_image" title="Remove Selected File"  src="../images/remove.gif" style="width:16px;height:16px;border:0;opacity:0.4"/>
            </a>
        </form>
        
        
         
        <a4j:commandButton title="Next" image="../images/next.gif" id="next" style="width:16px; height:16px;border:0"/>
        <a4j:commandButton title="Previuse" image="../images/previuse.gif" id="previuse" style="width:16px; height:16px;border:0"/>
        <a4j:commandButton title="Top" image="../images/top.gif" id="top" style="width:16px; height:16px;border:0"/>
        
        <a4j:commandButton title="End" image="../images/end.gif" id="end" style="width:16px; height:16px;border:0"/>
        <a4j:commandButton title="Help" image="../images/help.gif" id="help" style="width:16px; height:16px;border:0"/>
        <s:link title="Print Data" target="_blank" style="border:0" rendered="#{menuManager.pageUrl=='../security/data.seam'}" view="/security/dataPrint.seam">
            <h:graphicImage value="../images/print.gif" style="border:0"/>
        </s:link>  
    </rich:toolBarGroup>
    </rich:toolBar>
     
   
      
    <h:form id="filesForm" >
        <a4j:include viewId="loading.xhtml"/>
        
         
            
             <input type="hidden" id="validProps" value="#{uploadBean.validationProperties}" />
             <input type="hidden" id="xlsPatterns" value="#{uploadBean.patterns}"/>
             
              
             <rich:tabPanel >
             <rich:tab label="File Manager" reRender="data_toolbar">
             <table align="left" width="100%" style="font-size:12px">
                <tr>
                    <td>
                        #{messages['fina2.web.user']}
                    </td>
                    <td>
                        FI
                    </td>
                    <td>
                        #{messages['fina2.web.status']}
                    </td>
                    <td>
                        #{messages['fina2.web.from']}
                    </td>
                    <td>
                        #{messages['fina2.web.to']}
                    </td>
                    <td>Search By</td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>

                <tr>
                    <td>
                        <rich:comboBox id="data_users" width="70px" disabled="#{(!userSession.currentUserSa())&amp;&amp;((userSession.hasPermission('fina2.web.external.user'))&amp;&amp;(!userSession.hasPermission('fina2.web.internal.user')))}" value="#{uploadBean.uploadedFile.username}"  enableManualInput="false">
                            <f:selectItems value="#{uploadBean.users}"/>
                        </rich:comboBox>
                    </td>   
                    <td>
                        <rich:comboBox id="data_banks" width="70px" disabled="#{(!userSession.currentUserSa())&amp;&amp;((userSession.hasPermission('fina2.web.external.user'))&amp;&amp;(!userSession.hasPermission('fina2.web.internal.user')))}" value="#{uploadBean.uploadedFile.bankCode}" enableManualInput="false">
                          <f:selectItems  value="#{uploadBean.banks}" />
                        </rich:comboBox>
                    </td>
                    <td>
                        <rich:comboBox width="90px" value="#{uploadBean.uploadedFile.status}" enableManualInput="false">
                            <f:selectItems value="#{uploadBean.statuses}" />
                        </rich:comboBox>
                    </td>   
                        
                    <td >
                        <rich:calendar inputSize="10" buttonIcon=" " id="date_from" value="#{uploadBean.uploadedFile.fromDate}"/>
                    </td>
                
                    <td>
                        <rich:calendar inputSize="10" buttonIcon=" " id="date_to" value="#{uploadBean.uploadedFile.toDate}"/>
                    </td>
                    
                    <td>
                        <rich:comboBox width="100px" value="#{uploadBean.uploadedFile.periodCriteria}" enableManualInput="false">
                            <f:selectItems value="#{uploadBean.periodCriterias}"/>
                        </rich:comboBox>
                    </td>
                 
                    <td align="center">
                        <a4j:commandButton style="width : 55px" action="#{uploadFileSession.loadUploadedFiles(uploadBean.uploadedFile)}" value="#{messages['fina2.web.search']}"  onclick="Richfaces.showModalPanel('loading')" oncomplete="updateToolBar()" reRender="sc1,files,file_ids,enable_select_deselect">
                          
                        </a4j:commandButton>
                        <s:div id="file_ids">
                          <input id="file_item_ids" type="hidden" value="#{uploadFileSession.getFileIds()}"/>
                        </s:div>
                        
                          
                    </td>   
                    <td align="center">
                        <input type="button" onclick="flushFiles();Richfaces.showModalPanel('uploadFile');" value="#{messages['fina2.web.upload']}"  style="width : 55px" >
                          
                        </input>
                        
                    </td>
                    <td align="center">
                      
                    </td>
                </tr>
            </table>
            
            </rich:tab>
            </rich:tabPanel> 
            <rich:spacer height="5px"/>
            
            <f:facet name="header">
                #{messages['fina2.web.datatable']}
            </f:facet>
            
            <rich:datascroller oncomplete="viewSelected()" align="center" for="files" id="sc1" reRender="files"/>
            
            <rich:dataTable rows="15" align="center" reRender="sc1" id="files" style="width :100%" var="file" value="#{uploadFileSession.loadUploadedFiles(uploadBean.uploadedFile)}">
               
                <f:facet name="header">
                    <s:div>
                        <table align="right">
                            <tr>
                                <td>
                                   <div id="header_line_label" style="font-size:11px;">
                                     #{uploadFileSession.getUploadedFiles().size()} Files By Filter
                                   </div>
                                </td>
                            </tr>
                        </table>
                    </s:div>
                </f:facet>
                <f:facet name="footer">
                    <s:div>
                        <table align="right">
                            <tr>
                                <td>
                                    <div id="footer_line_label">
                                      <input type="text" disabled="true" value="Last Action Status:Done" style="font-size:11px"/>
                                   </div>
                                </td>
                                <td>
                                   <div id="footer_line_label">
                                      <input type="text" id="footer_files_number" disabled="true" style="font-size:11px"/>
                                      <script type="text/javascript">
                                        var v=document.getElementById("header_line_label").innerHTML;
                                        if(v!=null) {
                                            document.getElementById("footer_files_number").value=v.trim();
                                        }
                                        else 
                                            document.getElementById("footer_files_number").value="0 Files By Filter";
                                      </script>
                                   </div>
                                </td>
                            </tr>
                        </table>
                    </s:div>
                </f:facet>
             
               
                <rich:column sortBy="#{file.username}" style="text-align :center" colspan="3">
                    <f:facet name="header">
                        #{messages['fina2.web.user']}
                    </f:facet>
                    #{file.username}
                </rich:column>
            
                <rich:column sortBy="#{file.bankCode}" style="text-align :center" colspan="3">
                    <f:facet name="header">
                        FI
                    </f:facet>
                    #{file.bankCode}
                </rich:column>
        
                <rich:column sortBy="#{file.fileName}" style="text-align :center" colspan="3">
                    <f:facet name="header">
                        #{messages['fina2.web.file']}
                    </f:facet>
                    <a href="Download?id=#{file.id}">
                     #{file.fileName}
                    </a>
                     
                </rich:column>
        
                <rich:column sortBy="#{file.uploadedTime}" style="text-align :center" colspan="3">
                    <f:facet name="header">
                        #{messages['fina2.web.uploadTime']}
                    </f:facet>
                    <h:outputText value="#{file.uploadedTime}" >
                        <s:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                    </h:outputText>
                </rich:column>
        
                <rich:column sortIcon="../images/uploaded.gif" style="text-align :center" colspan="3">
                    <f:facet name="header">
                        #{messages['fina2.web.status']}
                    </f:facet>
                    <a4j:commandLink  onclick="Richfaces.showModalPanel('loading')" action="#{uploadBean.viewValidation(file.id)}" oncomplete="Richfaces.hideModalPanel('loading');Richfaces.showModalPanel('validationResults')" ajaxSingle="true" reRender="validationTable,files,xls_rets,validationResults" id="validation">
                        <a4j:actionparam name="file_id" value="#{file.id}" assignTo="#{uploadFileSession.fileId}" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.uploaded'}" value="../images/uploaded.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.converted'}" value="../images/converted.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.rejected'}"  value="../images/rejected.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.uploaded.validated'}"  value="../images/uploaded_validated.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.uploaded.not.validated'}"  value="../images/uploaded_not_validated.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.uploaded.converted'}"  value="../images/uploaded_converted.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.uploaded.not.converted'}"  value="../images/uploaded_not_converted.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.uploaded.processed'}"  value="../images/uploaded_processed.gif" />
                        <h:graphicImage style="border:0" title="#{messages[file.status]}" rendered="#{file.status == 'fina2.web.uploaded.error.processing'}"  value="../images/converted.gif" />
                    </a4j:commandLink>
                    
                </rich:column>
               
                <rich:column rendered="#{userSession.currentUser.login.trim()=='sa'}" sortIcon="../images/remove.gif" width="5%" style="text-align:center" colspan="3">
                    <f:facet name="header">
                        <s:div id="enable_select_deselect">
                        <input id="select_deselect"  type="checkbox" onchange="selectDeselectAll()"/>
                           
                           
                        </s:div>
                    </f:facet>
                    
                    <input id="#{file.id}" type="checkbox" onchange="saveUpdateId(this)" />      
                </rich:column>
                

            </rich:dataTable>
            
          
        </h:form>
        
      
        
        
        <rich:modalPanel id="validationResults" resizeable="false" autosized="true" width="400" height="130">
          <f:facet name="header">
             Validation And XML Files
          </f:facet>
          <f:facet name="controls">
              <img src="../images/close.gif" onclick="Richfaces.hideModalPanel('validationResults')" />
          </f:facet>
          
          <rich:tabPanel switchType="client">
          <rich:tab label="#{messages['fina2.web.xls.validation.info']}">
          <a4j:form>
          <s:div id="validationTable">
          
          <table style="font-size: 12px;" align="center">
           <tr>
            <td>#{messages['fina2.dcs.matrix.valid']} : <b>#{messages[uploadBean.matrixReason]}</b></td>
            <td><rich:spacer width="15px"/></td>
            <td>
             <h:graphicImage rendered="#{uploadBean.xlsMatrixValid}" style="border:0" value="../images/checked.gif"/>
             <h:graphicImage rendered="#{!uploadBean.xlsMatrixValid}" style="border:0" value="../images/abort.gif"/>
            </td>
           </tr>
           <tr>
            <td>#{messages['fina2.web.xls.name.valid']}</td>
            <td><rich:spacer width="15px"/></td>
            <td>
             <h:graphicImage rendered="#{uploadBean.xlsFileNameValid}" style="border:0" value="../images/checked.gif"/>
             <h:graphicImage rendered="#{!uploadBean.xlsFileNameValid}" style="border:0" value="../images/abort.gif"/>
            </td>
           </tr>
           <tr>
             <td>Check if file is 2003 Microsoft Excel file</td>
             <td><rich:spacer width="15px"/></td>
             <td>
              <h:graphicImage rendered="#{uploadBean.xlsFile}" style="border:0" value="../images/checked.gif"/>
              <h:graphicImage rendered="#{!uploadBean.xlsFile}" style="border:0" value="../images/abort.gif"/>
             </td> 
           </tr>
           <tr>
             <td>
                 <h:outputText rendered="#{!uploadBean.xlsProtected}" value="Following xls sheets protection dont confirm to matrixs sheets protection #{uploadBean.unconfirmedSheets}"/>
                 <h:outputText rendered="#{uploadBean.xlsProtected}" value="#{messages['fina2.web.xls.protected']}"/>
             </td>
             
             <td><rich:spacer width="15px"/></td>
             <td>
              <h:graphicImage rendered="#{uploadBean.xlsProtected}" style="border:0" value="../images/checked.gif"/>
              <h:graphicImage rendered="#{!uploadBean.xlsProtected}" style="border:0" value="../images/abort.gif"/>
             </td> 
           </tr>
           <tr>
            
           </tr>
           <tr>
             <td>#{messages['fina2.web.user.bank']}</td>
             <td><rich:spacer width="15px"/></td>
             <td>
              <h:graphicImage rendered="#{uploadBean.hasUserBank}" style="border:0" value="../images/checked.gif"/>
              <h:graphicImage rendered="#{!uploadBean.hasUserBank}" style="border:0" value="../images/abort.gif"/>
             </td> 
           </tr>
          </table>
          
          </s:div>
          </a4j:form>
          </rich:tab>
          
          <rich:tab label="Returns">
          <s:div id="xls_rets">
          <h:form>
          <div align="right">
              <a4j:commandButton action="#{uploadFileSession.loadXmls()}" value="Refresh" reRender="xmls_table"/>
          </div>
          <rich:datascroller for="xmls_table" align="center" />
          <div style="overflow-y:auto;width:100%;height:40%">
          
          <rich:dataTable rows="10" id="xmls_table" align="center" width="100%" value="#{uploadFileSession.getXmls()}" var="ir">
              <rich:column style="text-align:center">
                <f:facet name="header">
                    Code
                </f:facet>
                #{ir.returnCode}
              </rich:column>
              
              <rich:column style="text-align:center">
                  <f:facet name="header">
                      Type
                  </f:facet>
                      #{messages[ir.type.getCode()]}
              </rich:column>
              
              <rich:column style="text-align:center">
                  <f:facet name="header">
                      Version
                  </f:facet>
                      #{ir.versionCode}
              </rich:column>
              
              <rich:column style="text-align:center">
                  <f:facet name="header">
                      Import Start
                  </f:facet>
                      #{ir.importStart}
              </rich:column>
              
              <rich:column style="text-align:center">
                  <f:facet name="header">
                      Import End
                  </f:facet>
                      #{ir.importEnd}
              </rich:column>
              
              <rich:column style="text-align:center">
                  <f:facet name="header">
                      Status
                  </f:facet>
                      <h:outputText value="#{messages['fina2.returns.import.status.uploaded']}" rendered="#{ir.status==0}"/>
                      <h:outputText value="#{messages['fina2.returns.import.status.in_progress']}" rendered="#{ir.status==1}"/>
                      <h:outputText value="#{messages['fina2.returns.import.status.queued']}"  rendered="#{ir.status==2}"/>
                      <h:outputText value="#{messages['fina2.returns.import.status.rejected']}" rendered="#{ir.status==3}"/>
                      <h:outputText value="#{messages['fina2.returns.import.status.imported']}" rendered="#{ir.status==4}"/>
              </rich:column>
              
              <rich:column style="text-align:center">
                  <f:facet name="header">
                      Message
                  </f:facet>
                  
                 <h:inputTextarea readonly="true" style="font-size: 11px;height:20px" rows="20" value="#{ir.message}" />
                 
              </rich:column>
          </rich:dataTable> 
          </div>
          </h:form>
          </s:div>     
          </rich:tab>
          </rich:tabPanel>

        </rich:modalPanel>
        
       
        
        
        <rich:modalPanel  id="uploadFile" autosized="true" resizeable="false">
            <f:facet name="header">
               #{messages['fina2.web.uploadFiles']}
            </f:facet>
            
            <f:facet name="controls">
                <img src="../images/close.gif" onclick="Richfaces.hideModalPanel('uploadFile')" />
            </f:facet>
            
            <form name="uploadForm" action="Upload" enctype="multipart/form-data" method="post">
              <table width="100%" style="font-size:12px">
                  <tr>
                      <td>
                          <div align="center">
                              <input id="browse_files"  type="file" name="uploads[]" multiple="true" onchange="listFiles()" />
                          </div>
                      </td>
                  </tr>
                  <tr>
                      <td>
                          <div id="file_list_note" style="width:300px;font-size:12px;height: 13px">
                          </div>
                      </td>
                  </tr>
                  <tr> 
                      <td>
                          <div id="file_list_to_upload" style="overflow-x:auto;overflow-y:auto">
                              <table width="100%" cellpadding="0" cellspacing="0" align="center"  style="border:1px solid #C0C0C0;text-align:center;font-size:12px;">
                                  
                              </table>
                          </div>
                      </td>
                  </tr>
                  
                          
                  
                  <tr>
                      <td>
                           <br/>
                  
                           <input id="up_files"  onclick="Richfaces.hideModalPanel('uploadFile');Richfaces.showModalPanel('loading');" disabled="true" type="submit" value="Upload"/>
                           
                      </td>
                  </tr>
                  
               </table>       
            </form>
        </rich:modalPanel>
       
          </body>
</html>